SMODS.RunSelectPage#
(Added in 26.829)
Run Select is an integration of the mod Galdur within SMODS itself. This allows for easier customisation of runs before they begin, letting users choose different things that will affect the run. Deck and Stake choice are added by default, but more pages can be added easily.
Required parameters:
key: The key used to identify your page
Optional parameters (defaults):
page: Choose a position for your page to appear (1 = before deck, 2 = between deck and stake). Pages automatically get placed after stake selection.include_deck_preview: Set to true to automatically include the currently selected deck preview elementinclude_stake_tower: Set to true to automatically include the currently selected stake preview elementautomatic_preview: Set to true to automatically add a preview element for your selectionselection_limit: Set to the number of selections you can make, (defaults to 1)preview_size: Set to control the number of copies of each choice that are added to the automatic preview, (defaults to 1 orstack_sizeif defined)random_select: Set to true to automatically include a random buttongrid_size: Set as a table,{number_of_rows, number_of_columns}, of dimensions for the automatic selection element, (defaults to{2,5})sprite_size: Set as a table,{w = number, h = number}, to change the size of the cards in the automatic selection element, (defaults to{w = G.CARD_W, h = G.CARD_H})stack_size: Set to control the number of copies of each selection object that are added to the automatic selection element, (defaults to 1)area_type: Set as aCardAreatype to change the type of theCardAreaswithin the automatic selection and preview elementssilent: Set to true to remove animations from your pagetype: Set to the set of the object to automatically control the selection text
API methods#
generate_pool(self) -> tableTo determine the pool of objects used in the selection UI. Returns a table of objects
set_default(self, choice) -> stringControl what the page has selected when it is first encountered in a session (defaults to last choice)
selected_text(self, selection) -> stringControl the text that is displayed in the automatic preview UI
quick_start_text(self, choice) -> stringControl the text that is displayed in the tooltips
The quick start button calls this function with the last choice, and the play button calls this function with the current selection
start_run(self, choice)Execute code after the run is started
can_continue(self) -> booleanDetermine whether the user can progress to the next page or not
Return
trueto allow progress
optional(self) -> booleanDetermine whether the page should be able to be progressed to
Return
trueto display the page
create_selection_card(self, key, index, area) -> CardControl how the cards in the selection and preview UIs are created
Useful for modifying cards to add extra things to them
choose_random(self)Modify the behaviour of the random button
handle_choice(self, choice, remove)Modify the behaviour of clicking on selections
settings(self) -> tableReturn a table of UI nodes to be automatically added to the page
Useful for adding toggles and sliders
definition(self) -> UIElementReturn a custom UI to be used on the page
Localization#
Random select button:
run_select_MODPREFIX_PAGEKEY_randomNext page button:
run_select_MODPREFIX_PAGEKEY
Example#
Here is an example of a Run Select Page that allows the player to select a Rare Joker to acquire at the beginning of the run if you are playing on Red Deck.
local mod_prefix = 'eremel_testing' -- Replace with your own prefix
SMODS.RunSelectPage({
key = 'joker_choice',
grid_size = {2, 4}, -- Custom grid size
automatic_preview = true,
type = 'Joker',
generate_pool = function(self)
local pool = {}
for _, v in ipairs(G.P_CENTER_POOLS.Joker) do
if v.rarity == 3 then table.insert(pool, v) end
end
return pool
end,
optional = function(self) -- Only appear if Red Deck is selected
return SMODS.RunSelect.Setup.choices.deck_choice == 'b_red'
end,
quick_start_text = function()
if not G.PROFILES[G.SETTINGS.profile].last_choices[mod_prefix..'_joker_choice'] then return end -- If no Joker was selected last time, don't add to the tooltip
return localize({type = 'name_text', set = 'Joker', key = G.PROFILES[G.SETTINGS.profile].last_choices[mod_prefix..'_joker_choice']})
end,
start_run = function(self, choice) -- Add the Joker on run start
G.E_MANAGER:add_event(Event({
trigger = 'after', delay = 0.7,
func = function()
local c = SMODS.add_card({key = choice, skip_materialize = true})
c:start_materialize()
return true
end
}))
end,
set_default = function(self, choice) -- Make sure that the default selection is empty
return nil
end,
})